package com.cskaoyan.javase.oop2._2polymorphic._1basic;

/**
 * 接下来用两句话,总结"对象名点"访问成员变量,以及调用成员方法的特点:
 *      1."对象名点成员变量" 编译时(访问范围)看左边,运行时(访问结果)还看左边
 *      2."对象名点成员方法" 编译时(访问范围)看左边,运行时(访问结果)还看右边
 *
 * @since 11:41
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        Father fs;
        fs = new Son1();
        System.out.println(fs.num);
        fs.test();
        fs = new Son2();
        System.out.println(fs.num);
        fs.test();

        fs = new Son3();
        System.out.println(fs.num);
        fs.test();

    }
}

class Father {
    int num = 10;
    public void test(){
        System.out.println("father");
    }
}

class Son1 extends Father {
    int num = 20;
    @Override
    public void test(){
        System.out.println("son1");
    }
}

class Son2 extends Father {
    int num = 30;
    @Override
    public void test(){
        System.out.println("son2");
    }

}

class Son3 extends Father {
    int num = 40;
    @Override
    public void test(){
        System.out.println("son3");
    }
}